import { ApiProperty } from '@nestjs/swagger';
import { Exclude } from 'class-transformer';
import { IsNotIn, IsString, MaxLength, MinLength } from 'class-validator';

export class CreateUserDto {
  @ApiProperty({ type: String, description: '用户昵称' })
  // @IsString()
  username: string;

  @ApiProperty({ type: String, description: '用户登录密码' })
  @MinLength(6, {
    message: '密码长度不能小于6位数',
  })
  @MaxLength(200, {
    message: '密码长度不能超过200位数',
  })
  @IsNotIn(['', undefined, null], { message: '密码不能为空' })
  // @Matches(/((?=.*\d)|(?=.*W+))(?![.\n])(?=.*[a-z])(?=.*[A-Z]).*$/, {message: '密码中需包含数字、大写字母、小写字母以及特殊符号！'}) // 匹配字符串中包含数字、大写、小写字母、特殊符号
  @Exclude({ toPlainOnly: true }) // 输出屏蔽密码
  password: string;
  // 隐藏

  @MinLength(4)
  @MaxLength(32)
  @ApiProperty({ type: String, description: '用户登录账号' })
  @IsString()
  @IsNotIn(['', undefined, null], { message: '账号不能为空' })
  account: string;

  @ApiProperty({ type: String, description: '手机号', required: false })
  // @IsString()
  // @IsPhoneNumber()
  phoneNum: string;

  @ApiProperty({ type: String, description: '邮箱', required: false })
  // @IsString()
  // @IsEmail()
  email: string;

  @ApiProperty({ type: String, description: '头像url', required: false })
  // @IsString()
  avatar: string;
}
